﻿using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using Unity.Cinemachine;
using UnityEngine;
using YooAsset;
using Transform = UnityEngine.Transform;
using Newtonsoft.Json.Linq;
using System.Threading.Tasks;
using System.Xml.Linq;
using System.Linq;
using UnityEditor;
using System.Collections;
using Panty.QF;
using SimpleJSON;

namespace Panty.Test
{
    #region 网络相关CMD

    /// <summary>
    /// GGELUA网络断开
    /// </summary>
    public struct IQueryToGGEServerNetDisConnect : ICmd
    {
        public readonly void Do(IModuleHub hub)
        {
            hub.Module<IToGGEServerNetModule>().Dispose();
            //hub.Module<IWebSocketToGGEModule>().CloseWebSocket();
        }
    }
    /// <summary>
    /// GGELUA网络IP连接设置
    /// </summary>
    public struct IQueryToGGEServerNetConnect : IQuery<(string ip, int Port), Task<bool>>
    {
        public async readonly Task<bool> Do(IModuleHub hub, (string ip, int Port) info)
        {
            return await hub.Module<IToGGEServerNetModule>().Connect(info.ip, info.Port);
            //return await hub.Module<IWebSocketToGGEModule>().ConnectAsync(info.ip, info.Port);
        }
    }

    /// <summary>
    /// GGELUA网络数据发送,注意发送的是json化的字符串
    /// </summary>
    public struct ICmdToGGEServerNetSendMsg : ICmd<(float 序号, string 内容列表)>
    {

        public readonly void Do(IModuleHub hub, (float 序号, string 内容列表) info)
        {
            hub.Module<IToGGEServerNetModule>().SendMsg(info.序号, info.内容列表);
           // hub.Module<IWebSocketToGGEModule>().SendMsg(info.序号, info.内容列表);
        }
    }

    /// <summary>
    /// GGE接收到服务端网络数据
    /// </summary>
    public struct ICmdGGEServerToClientMsg : ICmd<string>
    {
        public async readonly void Do(IModuleHub hub, string 内容列表)
        {
            //Debug.Log(内容列表);
            // 解析JSON数据
            Dictionary<string, object> parsedData = JsonConvert.DeserializeObject<Dictionary<string, object>>(内容列表);
            float 序号 = Convert.ToSingle(parsedData["序号"]);
            object 内容 = parsedData["内容"];
            // 转发到网络处理类
            switch (序号)
            {
                case 1:
                    break;
                case 2:
                    break;
                case 3:
                    break;
                case 3.1f:
                    hub.EnumEvent(E_UICanvasEvt.注册完成);
                    break;
                case 4:
                    hub.EnumEvent(E_UICanvasEvt.登录成功, 内容);
                    break;
                case 5:
                    HandleEnterGame(hub, 内容);
                    break;
                case 6:
                    break;
                case 7:
                    hub.EnumEvent(E_UICanvasEvt.提示, 内容.ToString());
                    break;
                case 10:
                    HandlePlayerData(hub, 内容);
                    break;
                case 16:
                    await Task.Delay(500); //执行等待1s钟
                    HandlePetData(hub, 内容, 1);
                    break;
                case 17:
                    HandlePetData(hub, 内容, 2);
                    break;
                //case 27:
                //    HandleSystemChar(hub, 内容);
                //    break;
                case 38:
                    await Task.Delay(500); //执行等待1s钟
                    HandleSystemChar(hub, 内容);
                    break;
                case 40:
                    HandleTaskBar(hub, 内容);
                    break;
                case 77:
                    HandleSystemChar(hub, 内容);
                    break;
                case 113:
                    HandleSystemChar(hub, 内容);
                    break;
                case 998:
                    HandleExitGame(hub, 内容);
                    break;
                case 1005:
                    HandleSetPlayerData(hub, 内容);
                    break;
                case 1006:
                    JObject jsonObject = JObject.Parse(内容.ToString());
                    HandleLoadOtherPlayerData(hub, jsonObject);
                    break;
                case 1007:
                    HandlerUpdateOtherPlayerReMoveData(hub, 内容);
                    break;
                case 1008:
                    HandlerUpdateOtherPlayerMoveData(hub, 内容);
                    break;
                case 1015:
                    HandleLoadMapUnitAsync(hub, 内容);
                    break;
                case 1017:
                    HandlerLoadOtherPlayerChar(hub, 内容, 0);
                    break;
                case 1018:
                    HandlerLoadOtherPlayerChar(hub, 内容, 1);
                    break;
                case 1022:
                    JArray jsonObject1 = JArray.Parse(内容.ToString());
                    foreach (var dictionarys in jsonObject1)
                    {
                        if (dictionarys is JObject jobectItem)
                        {
                            HandleLoadOtherPlayerData(hub, jobectItem);
                        }
                    }
                    break;
                case 1501:
                    HandleChatData(hub, 内容);
                    break;
                case 3501:
                    HandleItemData(hub, 内容, 1);
                    break;
                case 3502:
                    HandleItemData(hub, 内容, 2);
                    break;
                case 3503:
                    HandleEquipmentData(hub, 内容);
                    break;
                case 3504:
                    await PlayersMonoSingleton.Instance.SetEquipmentShow();
                    break;
                case 3505:
                    PlayersMonoSingleton.Instance.UnLoadWeaponWasAnimtion();
                    break;
                case 3531:
                    HandleItemData(hub, 内容, 3);
                    break;
                case 3699:
                    hub.EnumEvent(E_UICanvasEvt.刷新道具数据);
                    break;
                case 4001:
                    CursourMono.Instance.SetCurrentCursorState(CursorIconState.组队);
                    break;
                case 4002:
                    break;
                case 4004:
                    break;
                case 4006:
                    PlayersMonoSingleton.Instance.captainSwitch = true;
                    break;
                default:
                    break;
            }
        }

       
        /// <summary>
        /// 进入游戏处理
        /// </summary>
        /// <param name="hub"></param>
        /// <param name="内容"></param>
        private readonly async void HandleEnterGame(IModuleHub hub, object 内容)
        {
            JObject jsonObject = JObject.Parse(内容.ToString());
            var dynamicDictionary = UtilsController.Instance.ConvertJObjectToDynamicDictionary(jsonObject);
            hub.EnumEvent(E_UICanvasEvt.选择角色, false);
            hub.EnumEvent(E_UICanvasEvt.主界面, true);
            hub.EnumEvent(E_UICanvasEvt.进入游戏, dynamicDictionary);
        }
        private readonly void HandlePlayerData(IModuleHub hub, object 内容)
        {
            JObject jsonObject = JObject.Parse(内容.ToString());
            var dynamicDictionary = UtilsController.Instance.ConvertJObjectToDynamicDictionary(jsonObject);
            PlayersMonoSingleton.Instance.playerData = dynamicDictionary;
            hub.EnumEvent(E_UICanvasEvt.角色属性);
        }
        /// <summary>
        /// 获取道具数据
        /// </summary>
        /// <param name="hub"></param>
        /// <param name="内容"></param>
        private readonly void HandleItemData(IModuleHub hub, object 内容, int type)
        {
            JObject jsonObject = JObject.Parse(内容.ToString());
            var dynamicDictionary = UtilsController.Instance.ConvertJObjectToDynamicDictionary(jsonObject);
            PlayersMonoSingleton.Instance.itemData = dynamicDictionary;
            if(PlayersMonoSingleton.Instance.backPackOpenStatus == false)
            {
                hub.EnumEvent(E_UICanvasEvt.背包);
                PlayersMonoSingleton.Instance.backPackOpenStatus = true;
            }
            hub.EnumEvent(E_UICanvasEvt.道具切换, type);
        }
        /// <summary>
        /// 获取人物装备数据
        /// </summary>
        /// <param name="hub"></param>
        /// <param name="内容"></param>
        private readonly void HandleEquipmentData(IModuleHub hub, object 内容)
        {
            JArray jsonObject = JArray.Parse(内容.ToString());
            List<object> 装备列表 = new();
            foreach (var item in jsonObject)
            {
                if (item == null)
                {
                    装备列表.Add(null);
                }
                else if (item is JObject jobectItem)
                {
                    装备列表.Add(jobectItem.ToObject<Dictionary<string, object>>());
                }
                else
                {
                    装备列表.Add(item);
                }
            }
            PlayersMonoSingleton.Instance.roleEquipmentInfo = 装备列表;
            hub.EnumEvent(E_UICanvasEvt.道具角色信息加载);
        }
        /// <summary>
        /// 获取召唤兽数据
        /// </summary>
        /// <param name="hub"></param>
        /// <param name="内容"></param>
        private readonly void HandlePetData(IModuleHub hub, object 内容, int s)
        {
            JArray jsonObject = JArray.Parse(内容.ToString());
            List<object> 召唤兽列表 = new();
            foreach (var item in jsonObject)
            {
                if (item == null)
                {
                    召唤兽列表.Add(null);
                }
                else if (item is JObject jobectItem)
                {
                    召唤兽列表.Add(jobectItem.ToObject<Dictionary<string, object>>());
                }
                else
                {
                    召唤兽列表.Add(item);
                }
            }
            PlayersMonoSingleton.Instance.petList = 召唤兽列表;
            hub.EnumEvent(E_UICanvasEvt.主界面召唤兽数据);
            if(s == 2)
            {
                hub.EnumEvent(E_UICanvasEvt.召唤兽);
            }
        }
        /// <summary>
        /// 接受系统消息数据
        /// </summary>
        /// <param name="hub"></param>
        /// <param name="内容"></param>
        /// <exception cref="NotImplementedException"></exception>
        private readonly void HandleSystemChar(IModuleHub hub, object 内容)
        {
            JObject jsonObject = JObject.Parse(内容.ToString());
            var jsonObjectDic = UtilsController.Instance.ConvertJObjectToDynamicDictionary(jsonObject);
            string noetion = (string)UtilsController.Instance.GetValueByKeyPath(jsonObjectDic, "内容");
            string pdName = (string)UtilsController.Instance.GetValueByKeyPath(jsonObjectDic, "频道");
            List<object> hyperLink = new List<object>();
            if (jsonObjectDic.ContainsKey("超链接"))
            {
                hyperLink = jsonObjectDic["超链接"] as List<object>;
            }
            hub.EnumEvent(E_UICanvasEvt.聊天内容添加, (noetion, pdName, hyperLink));
        }
        /// <summary>
        /// 处理玩家行走切换地图数据
        /// </summary>
        /// <param name="hub"></param>
        /// <param name="内容"></param>
        private readonly void HandleSetPlayerData(IModuleHub hub, object 内容)
        {
            int[] values = JsonConvert.DeserializeObject<int[]>(内容.ToString());
            UtilsController.Instance.SetValueByKeyPath(PlayersMonoSingleton.Instance.playerData, "地图数据.编号", values[0]);
            UtilsController.Instance.SetValueByKeyPath(PlayersMonoSingleton.Instance.playerData, "地图数据.x", values[1] * 20);
            UtilsController.Instance.SetValueByKeyPath(PlayersMonoSingleton.Instance.playerData, "地图数据.y", values[2] * 20);
            hub.EnumEvent(E_UICanvasEvt.切换地图);
        }
        /// <summary>
        /// 处理服务端NPC对话内容
        /// </summary>
        /// <param name="hub"></param>
        /// <param name="内容"></param>
        private readonly void HandleChatData(IModuleHub hub, object 内容)
        {
            var jsonObject = JObject.Parse(内容.ToString());
            string model = jsonObject["模型"].ToString();
            string name = jsonObject["名称"].ToString();
            string dialogue = jsonObject.ContainsKey("对话") ? jsonObject["对话"].ToString() : "";
            string[] options = jsonObject.ContainsKey("选项") ? jsonObject["选项"].ToObject<string[]>() : new string[0];
            hub.EnumEvent<E_UICanvasEvt, (string model, string names, string Data, string[] options)>(E_UICanvasEvt.NPC对话框显示, (model, name, dialogue, options));
        }
        /// <summary>
        /// 处理服务端任务数据
        /// </summary>
        /// <param name="hub"></param>
        /// <param name="内容"></param>
        private readonly void HandleTaskBar(IModuleHub hub, object 内容)
        {
            Debug.Log(内容.ToString());
            hub.EnumEvent(E_UICanvasEvt.显示任务栏);
        }
        /// <summary>
        /// 已在线玩家处理
        /// </summary>
        /// <param name="hub"></param>
        /// <param name="内容"></param>
        private readonly void HandleExitGame(IModuleHub hub, object 内容)
        {
            hub.EnumEvent(E_UICanvasEvt.提示, 内容.ToString());
            #if UNITY_EDITOR    //在编辑器模式下
                EditorApplication.isPlaying = false;
            #else
                Application.Quit();
            #endif
        }
        /// <summary>
        /// 加载地图单位，地图活动怪
        /// </summary>
        /// <param name="hub"></param>
        /// <param name="内容"></param>
        private readonly async void HandleLoadMapUnitAsync(IModuleHub hub, object 内容)
        {
            JObject jsonObject = JObject.Parse(内容.ToString());
            var dictionary = UtilsController.Instance.ConvertJObjectToDynamicDictionary(jsonObject);
            string 模型 = (string)UtilsController.Instance.GetValueByKeyPath(dictionary, "模型") ?? "护卫";
            
            string 名称 = (string)UtilsController.Instance.GetValueByKeyPath(dictionary, "名称") ?? "护卫";
            string id = (string)UtilsController.Instance.GetValueByKeyPath(dictionary, "id") ?? "";
            long 编号 = Convert.ToInt64(UtilsController.Instance.GetValueByKeyPath(dictionary, "编号") ?? 0);
            long 染色方案 = Convert.ToInt64(UtilsController.Instance.GetValueByKeyPath(dictionary, "染色方案") ?? 888);
            var 染色组 = UtilsController.Instance.GetValueByKeyPath(dictionary, "染色组");
            var 染色组1 = 染色组 is List<object> 染色组2 ? 染色组2.Select(item => Convert.ToUInt32(item)).ToList() : new List<uint> { 0, 0, 0 };
            string 当前称谓 = (string)UtilsController.Instance.GetValueByKeyPath(dictionary, "称谓") ?? "";
            string 武器 = (string)UtilsController.Instance.GetValueByKeyPath(dictionary, "武器") ?? "";

            long x = Convert.ToInt64(UtilsController.Instance.GetValueByKeyPath(dictionary, "x") ?? 0);
            long y = Convert.ToInt64(UtilsController.Instance.GetValueByKeyPath(dictionary, "y") ?? 0);
            long 方向 = Convert.ToInt64(UtilsController.Instance.GetValueByKeyPath(dictionary, "方向") ?? 0);
            var 地图编号 = Convert.ToInt64(UtilsController.Instance.GetValueByKeyPath(dictionary, "编号") ?? 0);
            //获取单位数据
            CharacterData data = UtilsController.Instance.characterDataDict[模型];
            //加载主控角色示例
            var go = await hub.Module<IResLoader>().AsyncLoad<GameObject>("DefaultPackage:NPC");
            var temp = go.InstantiateWithParent(GameObject.Find("GameMain(Clone)").transform).Position(new Vector3(x * 20, -y * 20, 0));

            var gos = temp.GetComponent<NpcMono>();
                
            gos.ChangeWasAnimtionDFSM("站立");
            gos.ChangeGroupAndPlayAnimation((int)方向); //设置当前人物方向
            gos.SetModleName(名称);
            gos.SetModleAppellation(当前称谓);
            gos.id = id;
            gos.编号 = (int)编号;
            gos.方向 = (int)方向;
            gos.武器名称 = 武器;
            gos.人物模型名称 = 模型;
            //加载角色信息
            await gos.LoadWasAnimtion($"{data.资源}_{data.站立}=站立", 染色方案, 染色组1);
            await gos.LoadWasAnimtion($"{data.资源}_{data.行走}=行走", 染色方案, 染色组1);
            await gos.SetEquipmentShow();
            //PlayersMonoSingleton.Instance.EmemyPlayers.Add();
        }
        /// <summary>
        /// 加载玩家信息
        /// </summary>
        /// <param name="hub"></param>
        /// <param name="内容"></param>
        private readonly async void HandleLoadOtherPlayerData(IModuleHub hub, JObject 内容)
        {
            var dictionary = UtilsController.Instance.ConvertJObjectToDynamicDictionary(内容);
            string 模型 = (string)UtilsController.Instance.GetValueByKeyPath(dictionary, "模型");
            string 名称 = (string)UtilsController.Instance.GetValueByKeyPath(dictionary, "名称");
            long 数字id = (long)UtilsController.Instance.GetValueByKeyPath(dictionary, "id");
            long 染色方案 = (long)UtilsController.Instance.GetValueByKeyPath(dictionary, "染色方案");
            var 染色组 = UtilsController.Instance.GetValueByKeyPath(dictionary, "染色组");
            var 染色组1 = 染色组 is List<object> 染色组2 ? 染色组2.Select(item => Convert.ToUInt32(item)).ToList() : new List<uint> { 0, 0, 0 };
            string 当前称谓 = (string)UtilsController.Instance.GetValueByKeyPath(dictionary, "当前称谓");
            long x = ((long)UtilsController.Instance.GetValueByKeyPath(dictionary, "x"));
            long y = ((long)UtilsController.Instance.GetValueByKeyPath(dictionary, "y"));
            long 方向 = (long)UtilsController.Instance.GetValueByKeyPath(dictionary, "方向");
            //加载主控角色示例
            var go = await hub.Module<IResLoader>().AsyncLoad<GameObject>("DefaultPackage:OtherPlayer");
            var temp = go.InstantiateWithParent(GameObject.Find("GameMain(Clone)").transform).Position(new Vector3(x, -y, 0));
            var gos = temp.GetComponent<otherPlayersMono>();
            gos.otherplayerData = dictionary;
            gos.ChangeWasAnimtionDFSM("站立");
            gos.ChangeGroupAndPlayAnimation(方向); //设置当前人物方向
            gos.SetModleName(名称);
            gos.SetModleAppellation(当前称谓);
            gos.数字id = (int)数字id;
            gos.方向 = 方向;
            gos.roleEquipmentInfo = (Dictionary<string, object>)UtilsController.Instance.GetValueByKeyPath(dictionary, "武器");
            gos.人物模型名称 = 模型;
            if (gos.roleEquipmentInfo != null && !string.IsNullOrEmpty((string)UtilsController.Instance.GetValueByKeyPath(gos.roleEquipmentInfo, "名称")))
            {
                long 武器子类 = (long)UtilsController.Instance.GetValueByKeyPath(gos.roleEquipmentInfo, "子类");
                模型 = $"{模型}_{UtilsController.Instance.GetWeaponSubType(武器子类)}";
            }
            //获取角色数据
            CharacterData data = UtilsController.Instance.characterDataDict[模型];
            //加载角色信息
            await gos.LoadWasAnimtion($"{data.资源}_{data.站立}=站立", 染色方案, 染色组1);
            await gos.LoadWasAnimtion($"{data.资源}_{data.行走}=行走", 染色方案, 染色组1);
            await gos.SetEquipmentShow();
            PlayersMonoSingleton.Instance.OPlayers.Add(gos.数字id,gos);
        }

        /// <summary>
        /// 当前同地图其他玩家移动时更新
        /// </summary>
        /// <param name="hub"></param>
        /// <param name="内容"></param>
        private readonly void HandlerUpdateOtherPlayerMoveData(IModuleHub hub, object 内容)
        {
            JObject jsonObject = JObject.Parse(内容.ToString());
            var dictionary = UtilsController.Instance.ConvertJObjectToDynamicDictionary(jsonObject);
            long 数字id = (long)UtilsController.Instance.GetValueByKeyPath(dictionary, "数字id");
            float x = (long)UtilsController.Instance.GetValueByKeyPath(dictionary, "路径.x");
            float y = (long)UtilsController.Instance.GetValueByKeyPath(dictionary, "路径.y");

            Vector2 endposlist = new (x, -y);
            if(PlayersMonoSingleton.Instance.OPlayers.ContainsKey((int)数字id))
            {
                var gos = PlayersMonoSingleton.Instance.OPlayers[(int)数字id];
                gos.SetOtherPlayerPosition(endposlist);
            }
        }
        
        /// <summary>
        /// 当其他玩家切换地图时移除其他玩家
        /// </summary>
        /// <param name="hub"></param>
        /// <param name="内容"></param>
        private readonly void HandlerUpdateOtherPlayerReMoveData(IModuleHub hub, object 内容)
        {
            JObject jsonObject = JObject.Parse(内容.ToString());
            var dictionary = UtilsController.Instance.ConvertJObjectToDynamicDictionary(jsonObject);
            long 数字id = (long)UtilsController.Instance.GetValueByKeyPath(dictionary, "id");
            PlayersMonoSingleton.Instance.OPlayers[(int)数字id].gameObject.DestroySelf(); //场景中移除自己
            PlayersMonoSingleton.Instance.OPlayers.Remove((int)数字id); //玩家维护字典中移除
        }
        /// <summary>
        /// 添加头顶聊天
        /// </summary>
        /// <param name="hub"></param>
        /// <param name="内容"></param>
        private readonly void HandlerLoadOtherPlayerChar(IModuleHub hub, object 内容, int type)
        {
            JObject jsonObject = JObject.Parse(内容.ToString());
            long 数字id = 0;
            var dictionary = UtilsController.Instance.ConvertJObjectToDynamicDictionary(jsonObject);
            if (type == 1)
            {
                数字id = (long)UtilsController.Instance.GetValueByKeyPath(dictionary, "id");
            }
            var 文本 = (string)UtilsController.Instance.GetValueByKeyPath(dictionary, "文本");
            hub.EnumEvent(E_UICanvasEvt.聊天头顶内容添加, (文本,(int)数字id)); //0表示自己
        }
    }



    #endregion

    #region 地图逻辑相关CMD
    /// <summary>
    /// 初始化地图
    /// </summary>
    public struct ICmdInitMap : ICmd<string>
    {
        public async void Do(IModuleHub hub, string info)
        {
            await hub.Module<INewMapModule>().InitMap(info);
        }
    }
    /// <summary>
    /// 初始化加载地图NPC
    /// </summary>
    public struct ICmdInitNpc : ICmd<(int, Vector2)>
    {
        public async void Do(IModuleHub hub, (int, Vector2) info)
        {
            hub.Module<IMapNpcSetModule>().InitNpc(info.Item1);
            //await hub.Module<IMapNpcSetModule>().SetNpcAoILoad(info.Item2);
            //hub.Module<IMapNpcSetModule>().LoadAOINpc(info.Item2);
            await hub.Module<IMapNpcSetModule>().SetAllNpcLoad();
        }

    }
    
    /// <summary>
    /// 获取可寻走路径
    /// </summary>
    public struct IQueryGetOBsPathFinding : IQuery<(Vector2 thisdpos, Vector2 endpos),List<Vector2>>
    {

        List<Vector2> IQuery<(Vector2 thisdpos, Vector2 endpos), List<Vector2>>.Do(IModuleHub hub, (Vector2 thisdpos, Vector2 endpos) info)
        {
            //"获取A*".Log();
            return hub.Module<INewMapModule>().GetAstart(info.thisdpos, info.endpos);
        }
    }

    /// <summary>
    /// 人物行走九宫格加载地图与遮罩
    /// </summary>
    public struct ICmdGetPoiontToSetImages : ICmd<Vector2>
    {
        public void Do(IModuleHub hub, Vector2 thispos)
        {
            hub.Module<INewMapModule>().SetAOIMapAndMask(thispos);
        }
    }
    /// <summary>
    /// 全图加载
    /// </summary>
    public struct ICmdLoadMapAll : ICmd
    {
        public void Do(IModuleHub hub)
        {
            hub.Module<INewMapModule>().LoadALLmap();
            hub.Module<INewMapModule>().LoadALLmapmask();
        }
    }
    /// <summary>
    /// 设置虚拟相机跟随与地图边界
    /// </summary>
    public struct ICmdSetCinemachine : ICmd<Transform>
    {
        public async void Do(IModuleHub hub, Transform pos)
        {
            //设置虚拟相机跟随
            var g = GameObject.Find("Camera").transform.GetComponent<CinemachineCamera>();
            g.Target.TrackingTarget = pos;

            //设置相机边界
            var poly2d = GameObject.Find("MapHandler").transform.GetComponent<PolygonCollider2D>();   
            var c2d = g.GetComponent<CinemachineConfiner2D>();
            hub.Module<INewMapModule>().SetMapLimit(c2d, poly2d);
        }
    }

    #endregion

    #region 通用工具相关CMD

    /// <summary>
    /// 延迟多少秒重复执行任务
    /// </summary>
    public struct ICmdSetITaskSchedulerAddDelayTask : ICmd<(float time, Action aciton, bool isloop)>
    {
        public void Do(IModuleHub hub, (float time, Action aciton, bool isloop) info)
        {
            hub.Module<ITaskScheduler>().AddDelayTask(info.time, info.aciton, info.isloop);
        }
    }

    /// <summary>
    /// 临时执行多少时间的任务
    /// </summary>
    public struct ICmdSetITaskSchedulerTemporaryTask : ICmd<(float time, Action aciton)>
    {
        public void Do(IModuleHub hub, (float time, Action aciton) info)
        {
            hub.Module<ITaskScheduler>().PeriodicExecute(info.time, info.aciton);
        }
    }

    #endregion

    #region 聊天处理相关

    /// <summary>
    /// 获取服务端聊天数据
    /// </summary>
    public struct IQueryChatData : IQuery<string>
    {
        public readonly string Do(IModuleHub hub)
        {
            return hub.Module<IChatDataCLModule>().SerrverChatdatas;        
        }
    }

    /// <summary>
    /// 获取客户端聊天超链接数据
    /// </summary>
    public struct IQueryChatLinkData : IQuery<List<(string Data, Vector2 mousePos, Sprite sprite, string name, string 超链接, string 识别码)>>
    {
        public readonly List<(string Data, Vector2 mousePos, Sprite sprite, string name, string 超链接, string 识别码)> Do(IModuleHub hub)
        {
            return hub.Module<IChatDataCLModule>().客户端超链接列表;
        }
    }
    /// <summary>
    /// 获取服务端超链接
    /// </summary>
    public struct IQueryServerChatLinkData : IQuery<List<(string Data, List<object> 超链接)>>
    {
        public readonly List<(string Data, List<object> 超链接)> Do(IModuleHub hub)
        {
            return hub.Module<IChatDataCLModule>().服务端超链接列表;
        }
    }
    #endregion

}
